package org.tuling.tlmalluseropenfeigndemo.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import org.tuling.tlmallcommon.Result;
import org.tuling.tlmalluseropenfeigndemo.feign.OrderFeignService;
import org.tuling.tlmalluseropenfeigndemo.feign.dto.OrderDTO;

@RestController
@RequestMapping("/user")
@Slf4j
public class UserController{

    @Autowired
    private OrderFeignService orderService;

    @RequestMapping(value = "/getOrder")
    public Result<?> getOrderByUserId(@RequestParam("userId") String userId) {
        log.info("根据userId:"+userId+"查询订单信息");

        //使用openFeign调用订单服务
        Result result = orderService.getOrder(userId);

        return result;
    }




//    @RequestMapping(value = "/post")
//    public Result<?>  post(@RequestBody OrderDTO orderDTO){
//        //测试 application/json
//        //Result result = orderService.post1(orderDTO);
//        //Result result = orderService.post2(orderDTO,"xxxxxxxxxxxxx");
//        Result result = orderService.post3(orderDTO,"fox");
//
//        return result;
//    }



}